package com.woniu.cinema.controller;

import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.woniu.common.annotation.Log;
import com.woniu.common.core.controller.BaseController;
import com.woniu.common.core.domain.AjaxResult;
import com.woniu.common.enums.BusinessType;
import com.woniu.cinema.domain.Hall;
import com.woniu.cinema.service.HallService;
import com.woniu.common.utils.poi.ExcelUtil;
import com.woniu.common.core.page.TableDataInfo;

/**
 * 影厅信息Controller
 * 
 * @author yy
 * @date 2021-04-16
 */
@RestController
@RequestMapping("/cinema/hall")
public class HallController extends BaseController
{
    @Autowired
    private HallService hallService;

    /**
     * 查询影厅信息列表
     */
    @GetMapping("/list")
    public TableDataInfo list(Hall hall)
    {
        startPage();
        List<Hall> list = hallService.selectHallList(hall);
        return getDataTable(list);
    }

    /**
     * 导出影厅信息列表
     */
    @Log(title = "影厅信息", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(Hall hall)
    {
        List<Hall> list = hallService.selectHallList(hall);
        ExcelUtil<Hall> util = new ExcelUtil<Hall>(Hall.class);
        return util.exportExcel(list, "hall");
    }

    /**
     * 获取影厅信息详细信息
     */
    @GetMapping(value = "/{hallId}")
    public AjaxResult getInfo(@PathVariable("hallId") Long hallId)
    {
        return AjaxResult.success(hallService.selectHallById(hallId));
    }

    /**
     * 新增影厅信息
     */
    @Log(title = "影厅信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Hall hall)
    {
        return toAjax(hallService.insertHall(hall));
    }

    /**
     * 修改影厅信息
     */
    @Log(title = "影厅信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Hall hall)
    {
        return toAjax(hallService.updateHall(hall));
    }

    /**
     * 删除影厅信息
     */
    @Log(title = "影厅信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{hallIds}")
    public AjaxResult remove(@PathVariable Long[] hallIds)
    {
        return toAjax(hallService.deleteHallByIds(hallIds));
    }
}
